const express = require('express');
const cors = require('cors');
const app = express();
const port = 3000;

// 允许跨域请求
app.use(cors());

// 模拟数据 - 实际应用中可从配置文件或数据库读取
const config = {
  //officialAccountUrl: 'https://cxk.snhaw.cn/',
  officialAccountUrl:'https://mp.weixin.qq.com/s/VcSSXZRWlbIH13rrKpkjtQ',
  customerServicePhone: '0771-2411006'
};

// 获取公众号URL接口
app.get('/getUrl', (req, res) => {
  res.json({
    code: 200,
    data: {
      url: config.officialAccountUrl,
      timestamp: new Date().getTime() // 添加时间戳防止缓存
    }
  });
});

// 获取客服电话接口
app.get('/getPhoneNum', (req, res) => {
  res.json({
    code: 200,
    data: {
      phone: config.customerServicePhone,
      timestamp: new Date().getTime() // 添加时间戳防止缓存
    }
  });
});

// 获取小程序信息接口
app.get('/getInfo', (req, res) => {
  res.json({
    code: 200,
    data: {
      appName: '天跃财税',
      company: '天跃财税有限公司',
      bannerUrl: 'https://cxk.snhaw.cn/gwz-admin-api/crmebimage/public/maintain/2025/06/20/dcbcef74acc140bd9c03f75a2758fa92fwxuqf8j99.jpg',
      timestamp: new Date().getTime() // 添加时间戳防止缓存
    }
  });
});

// 启动服务器
app.listen(port, () => {
  console.log(`Backend server running at http://localhost:${port}`);
});
